package com.mrx.xbrowsersync.controller;

import com.mrx.xbrowsersync.model.dto.BookmarkResponse;
import com.mrx.xbrowsersync.model.dto.InfoResponse;
import com.mrx.xbrowsersync.model.vo.BookmarkVO;
import com.mrx.xbrowsersync.service.IBrowserSyncService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mr.X
 * @since 2024-03-05 下午 7:28:20
 */
@RestController
public class XBrowserSyncController {

    @Resource
    private IBrowserSyncService browserSyncService;

    @PostMapping("/bookmarks")
    public BookmarkResponse createBookmarks(@RequestBody BookmarkVO vo) {
        return browserSyncService.createBookmarks(vo);
    }

    @GetMapping("/bookmarks/{id}")
    public BookmarkResponse getBookmarks(@PathVariable String id) {
        return browserSyncService.getBookmarks(id);
    }

    @PutMapping("/bookmarks/{id}")
    public BookmarkResponse updateBookmarks(@PathVariable String id, @RequestBody BookmarkVO vo) {
        vo.setId(id);
        return browserSyncService.updateBookmarks(vo);
    }

    @GetMapping("/bookmarks/{id}/lastUpdated")
    public BookmarkResponse getBookmarkLastUpdated(@PathVariable String id) {
        return browserSyncService.getBookmarkLastUpdated(id);
    }

    @GetMapping("/bookmarks/{id}/version")
    public BookmarkResponse getBookmarkSyncVersion(@PathVariable String id) {
        return browserSyncService.getBookmarkSyncVersion(id);
    }

    @GetMapping("/info")
    public InfoResponse info() {
        return browserSyncService.getServiceInfo();
    }

}
